import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

// API

// Utils

// Modules
import user from "./user"

const myPlugin = (store) => {
	store.subscribe((mutation, state) => {
		// 缓存状态
		uni.setStorageSync('stroeState', state)
	})

	uni.setStorageSync('stroeInitState', store.state)

	uni.getStorageSync('stroeState') && store.replaceState(uni.getStorageSync(
		'stroeState'));
}

const state = {

}

const getters = {}

const mutations = {}

const actions = {}

const store = new Vuex.Store({
	// 非生产环境添加严格模式
	strict: process.env.NODE_ENV !== 'production',
	state,
	getters,
	mutations,
	actions,
	// 模块
	modules: {
		user,
	},
	// 插件
	plugins: [myPlugin],
});

export default store;